<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    //实现calc的链式调用，关键在于返回this
    class calc
    {
        constructor(value)
        {
            this.value = value;
        }

        //add
        add(value)
        {
            this.value+=value;
            return this;
        }

        //sub
        sub(value)
        {
            this.value-=value;
            return this;
        }

        //multiple
        multiple(value)
        {
            this.value*=value;
            return this;
        }

        //divide
        divide(value)
        {
            this.value/=value;
            return this;
        }

        //get
        get()
        {
            return this.value;
        }
    }

    let value = new calc(9);
    console.log(value.add(10).multiple(2).divide(10).get());

</script>
<body>
    
</body>
</html>